﻿using BLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Models;
using Newtonsoft.Json.Linq;

namespace GoShopping.tools
{
    /// <summary>
    /// Detail 的摘要说明
    /// </summary>
    public class Detail : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            
            getByID(context);
        }

        private void getByID(HttpContext context)
        {
            //获取商品ID编号
            int t = int.Parse(context.Request.QueryString["tyID"]);
            //获取商品信息
            List<Models.Goods> list=new List<Models.Goods>();
            Models.Goods goods=GoodsBll.getByIDBLL(t);
            list.Add(goods);
            //转换为JSON格式
            JObject obj = new JObject();
            JArray array = JArray.FromObject(list);
            obj.Add("res", array);
            if (list.Count > 0)
            {
                context.Response.Write(obj);
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}